<div class="bjui-pageContent">

    <table class="table table-bordered" id="datagrid-test-filter" data-toggle="datagrid" data-options="{
        height: '100%',
        gridTitle : '产品列表',
<!--        showToolbar: true,-->
        local: 'remote',
        dataUrl: '/admin/pro/list',
        postData:{category_id:2},
        linenumberAll: true,
        sortAll: false,
        contextMenuH: true,
        contextMenuB: true,
        inlineEditMult: false,
        showCheckboxcol: true,
        paging: {showPagenum:10, selectPageSize:'20,50,100', pageCurrent:1, pageSize:20},
        fullGrid: true,
        fieldSortable: false,
        filterThead: false,
        columnMenu: false,
    }">
        <thead>
        <tr>
            <th data-options="{name:'id',align:'center',width:100}">ID</th>
            <th data-options="{name:'product_name',align:'center',width:100}">产品名称</th>
            <th data-options="{name:'img_url', render:'create_img_tag',align:'center',width:100}">产品图片</th>
            <th data-options="{name:'product_no',align:'center',width:100}">产品编号</th>
            <th data-options="{name:'number',align:'center',width:100}">可用库存</th>
            <th data-options="{name:'warning_number',align:'center',width:100}">预警库存</th>
            <th data-options="{name:'barcode',align:'center',width:100}">条形码</th>
            <th data-options="{name:'category_id', type:'select', items:datagrid_category, align:'center',width:300}">产品分类</th>
        </tr>
        </thead>
    </table>
</div>

<div class="bjui-pageFooter">
    <ul>
        <li><button type="button" class="btn-default" data-icon="save" onclick="pickMaterialSubmit();">确定</button></li>
        <li><button type="button" class="btn-close" data-icon="close">取消</button></li>
    </ul>
</div>

<script type="text/javascript">
    function create_img_tag(value){
        return '<img style="width:50px;" src="'+value+'">';
    }

    //后去被选中的材料id
    function pickMaterialSubmit(){

        var materialIds = '';
        var selectTrs = $('#datagrid-test-filter .datagrid-selected-tr');
        selectTrs.each(function(){
            var materialId = $(this).find("td[data-title='ID']").text();
            materialIds +=  materialId + ',';
        });
        materialIds=(materialIds.substring(materialIds.length-1)==',')?materialIds.substring(0,materialIds.length-1):materialIds;
        $('#id_material_{{$processId}}_{{$fieldName}}').val(materialIds);

        //关闭当前dialog
        BJUI.dialog('close','pick_{{$fieldName}}');
    }


</script>